﻿using Microsoft.Extensions.Configuration;
using MongoDB.Driver;

namespace Dreamwork.Core.Infrastructure.Mongodb
{
	public class MongoContext : IMongodbContext
	{
		public MongoContext(IConfiguration config)
		{
			string connectionString = config["MongoDB:ConnectionString"];
			MongoClientSettings settings = MongoClientSettings.FromUrl(
			  new MongoUrl(connectionString)
			);
			//settings.SslSettings =
			//  new SslSettings() { EnabledSslProtocols = SslProtocols.Tls12 };
			var mongoClient = new MongoClient(settings);
			if (mongoClient != null)
				Db = mongoClient.GetDatabase(config["MongoDB:Database"]);
		}
		public IMongoDatabase Db { get; }
		//public IMongoCollection<ApplicationUser> ApplicationUsers => _db.GetCollection<ApplicationUser>("ApplicationUsers");
	}
}
